package cn.yuanqiao.web.controller.archive.management;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.management.domain.YqZtlx;
import cn.yuanqiao.archive.management.service.IYqZtlxService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 载体类型Controller
 * 
 * @author sy
 * @date 2023-07-07
 */
@RestController
@RequestMapping("/archive/yqZtlx")
public class  YqZtlxController extends BaseController
{
    @Autowired
    private IYqZtlxService yqZtlxService;

    /**
     * 查询载体类型列表
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:list')")
    @GetMapping("/list")
    public TableDataInfo list(YqZtlx yqZtlx)
    {
        startPage();
        List<YqZtlx> list = yqZtlxService.selectYqZtlxList(yqZtlx);
        return getDataTable(list);
    }

    /**
     * 查询所有载体类型
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll()
    {
        YqZtlx yqZtlx = new YqZtlx();
        return success(yqZtlxService.selectYqZtlxListAll(yqZtlx));
    }

    /**
     * 导出载体类型列表
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:export')")
    @Log(title = "载体类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YqZtlx yqZtlx)
    {
        List<YqZtlx> list = yqZtlxService.selectYqZtlxList(yqZtlx);
        ExcelUtil<YqZtlx> util = new ExcelUtil<YqZtlx>(YqZtlx.class);
        util.exportExcel(response, list, "载体类型数据");
    }

    /**
     * 获取载体类型详细信息
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:query')")
    @GetMapping(value = "/{ztlxId}")
    public AjaxResult getInfo(@PathVariable("ztlxId") Long ztlxId)
    {
        return success(yqZtlxService.selectYqZtlxByZtlxId(ztlxId));
    }

    /**
     * 新增载体类型
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:add')")
    @Log(title = "载体类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YqZtlx yqZtlx)
    {
        return success(yqZtlxService.insertYqZtlx(yqZtlx));
    }

    /**
     * 修改载体类型
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:edit')")
    @Log(title = "载体类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YqZtlx yqZtlx)
    {
        return success(yqZtlxService.updateYqZtlx(yqZtlx));
    }

    /**
     * 删除载体类型
     */
//    @PreAuthorize("@ss.hasPermi('archive:yqZtlx:remove')")
    @Log(title = "载体类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ztlxIds}")
    public AjaxResult remove(@PathVariable Long[] ztlxIds)
    {
        return success(yqZtlxService.deleteYqZtlxByZtlxIds(ztlxIds));
    }
}
